package com.rms.hkpc.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.rms.hkpc.R;
import com.rms.hkpc.adapter.base.BasePagerAdapter;
import com.rms.hkpc.db.dto.WorkOrderPhotosDto;
import com.rms.hkpc.util.ImageUtil;

import java.util.List;

public class ImgBannerAdapter extends BasePagerAdapter<WorkOrderPhotosDto> {

    public ImgBannerAdapter(Activity activity, Context context, List<WorkOrderPhotosDto> mData, int layoutId) {
        super(activity, context, mData, layoutId);
    }

    @Override
    public Object convert(ViewGroup container, WorkOrderPhotosDto bean, int position) {
        ImageView iv = fd(R.id.iv_banner);
        ImageUtil.getInstance().loadImg(activity, bean.getPhoto(), iv);
        iv.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (onItemLongClickListener != null) {
                    onItemLongClickListener.onLongClickListener(v, position);
                }
                return false;
            }
        });
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null) {
                    onItemClickListener.onClickListener(v, position);
                }
            }
        });
        container.addView(iv);
        return iv;
    }
}
